import static org.junit.Assert.*;

import net.babelphish.altitudesig.SigElements.SigElement;
import net.babelphish.altitudesig.SigElements.SigElementJSONFactory;

import org.junit.Test;

import com.google.appengine.api.images.Image;
import com.google.appengine.api.images.ImagesServiceFactory;
import com.google.appengine.api.images.Composite.Anchor;


public class ParseStyle {

	@Test
	public void testGetSigStyleElement() {
		SigElementJSONFactory parseStyle = new SigElementJSONFactory();
		SigElement result = parseStyle.getSigStyleElement(
					"{ type        : 'composite',  " +
					"  _subelements : [{ type : 'conditionalImage', " +
					"					  conditionProperty : 'type'," + 
					"					  conditionKeys : {" +
					"									  ball : { type: 'image', filename: 'background-ball', " +
					"									  tbd :  { type: 'image', filename: 'background-tbd' }" +
					"								      }" +
					"				   }," +
					"				   { type : 'ratingsChart'" +
					"					 " +
					"				   }  " +
					"					]" +
					"}"
		);
		Image compositedImage = result.drawSelf(null);
		
	}

}
/*
imagesToComposite.add(ImagesServiceFactory.makeComposite(backgroundImage, 0, 0, 1, Anchor.TOP_LEFT));
imagesToComposite.add(ImagesServiceFactory.makeComposite(chartImage, -45, -15, 0.8f, Anchor.BOTTOM_RIGHT));
imagesToComposite.add(ImagesServiceFactory.makeComposite(chartTextImage, 151, 27, 1, Anchor.TOP_LEFT));

//draw nametag, badges and username
double totalNameTagWidth = leftNameTag.getWidth() + rightNameTag.getWidth();
imagesToComposite.add(ImagesServiceFactory.makeComposite(leftNameTag, (int)nameTagOffset, -1, 1, Anchor.TOP_LEFT));
imagesToComposite.add(ImagesServiceFactory.makeComposite(rightNameTag, (int)nameTagOffset + leftNameTag.getWidth(), -1, 1, Anchor.TOP_LEFT));
//add badges
imagesToComposite.add(ImagesServiceFactory.makeComposite(smallBadgeImage, (int)nameTagOffset + 7, 3, 0.8f, Anchor.TOP_LEFT));
imagesToComposite.add(ImagesServiceFactory.makeComposite(smallBadgeImage, (int)(nameTagOffset + totalNameTagWidth - (4 + smallBadgeImage.getWidth())), 3, 0.8f, Anchor.TOP_LEFT));
//add name
imagesToComposite.add(ImagesServiceFactory.makeComposite(usernameImage, (int)((nameTagOffset + (totalNameTagWidth / 2.0)) - (usernameImage.getWidth() / 2.0)) + 2, 5, 1, Anchor.TOP_LEFT));

byte[] finalImage = ImagesServiceFactory.getImagesService().composite(imagesToComposite, signatureWidth, signatureHeight, 0).getImageData();
*/